<template>
	<view class="container">
		<!-- 登录 -->
		<view class="toubu">
			<view class="toubu-logo">
				<image src="/static/icon/logo.png" mode=""></image>
			</view>
		</view>
		<view class="zhuanzhang">
			<text class="zhuanzhang1">{{$t('zhuan.xuanzhe')}}</text>
			<radio-group class="zuanzhe1" @change="radioChange">
				<label v-for="(item,index) in radioItems" :key="index">
					<view  class="zuanzhe2">
					<radio class="zuanzhe2-radio" borderColor="#e6e6e6" backgroundColor="#2d2d32" :value="item.value" :checked="index == current"></radio>
					<view>{{item.name}}</view>	
					</view>
				</label>
			</radio-group>
			<text class="zhuanzhang1">{{$t('zhuan.shurushulian')}}</text>
			<input class="zhuanzhang2" type="number" :placeholder="this.$t('kuan.qingshuru')" v-model="money"/>
		</view>
		<view class="queren" @click="sumbit">
			<text>{{$t('zhuan.quren')}}</text>
		</view>
	</view>
</template>

<script>
	import {
		Debounce
	} from "@/api/debounce.js"; //防抖
	export default {
		data() {
			return {
				radioItems: [{
						value: '0',
						name: 'USDT',
						checked: 'true'
					},
					{
						value: '1',
						name: 'USDK',
					},
					{
						value: '2',
						name: 'XGT',
					}
				],
				current:0,
				uid:'',
				money:'',
				typ:1,
			}
		},
		onLoad(options) {
			// 获取 yqm 参数值
			const dizhi = options.dizhi
			// console.log('打印地址',options);
			if(!dizhi){
				
			}else{
				//解密值
			this.uid =this.AES.decrypt(dizhi,'1234567891234567','1234567891234567')
			}
			
		},
		methods: {
			radioChange(e) {
				this.current=e.detail.value
				if(this.current==0){
					this.typ=1
				}else if(this.current==1){
					this.typ=2
				} if(this.current==2){
					this.typ=3
				}
				// console.log('typ',this.typ);
			},
			// 互转 
			sumbit:Debounce(function(){
				if(this.money<0){
					this.$modal.msg(this.$t('msg.error'))
					return
				}
				if(this.uid==""){
					this.$modal.msg(this.$t('msg.error2'))
					return
				}
				let data = {
					money: this.money,
					type: this.typ,
					uid:this.uid
				}
				let opts = {
					url: '/user/MomeyHz',
					method: 'POST'
				};
				// console.log('打印入参',data);
				this.api.httpsTokenRequest(opts, data).then(res => {
					// console.log('互转', res);
					if (res[1].data.state == 'success') {
						uni.showToast({
							title:res[1].data.msg,
							icon:"none"
						})
					}else{
						uni.showToast({
							title:res[1].data.msg,
							icon:"none"
						})
					}
				
				})
			},1000)
		},
	}
</script>

<style>
	.container{
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	/* 头部登录 */
	.toubu{
		width: 94%;
		padding: 20rpx;
		margin-top: 80rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
	.toubu-logo{
		width: 180rpx;
		height: 60rpx;
	}
	.toubu-youbian{
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.youbian-shu{
		width: 220rpx;
		height: 50rpx;
		border-radius: 30rpx;
		background-color: #5e5e5e;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;
		color: #ffffff;
		margin-right: 15rpx;
	}
	.youbian-logo{
		width: 60rpx;
		height: 60rpx;
		overflow: hidden;
		border-radius: 50%;
	}
	.zhuanzhang{
		width: 84%;
		padding: 25rpx;
		display: flex;
		flex-direction: column;
		background-color: #4e4e4e;
		border-radius: 20rpx;
		border: 1rpx solid #89b6f0;
		margin-top: 20rpx;
	}
	.zhuanzhang1{
		font-size: 36rpx;
		font-weight: 700;
		margin-left: 15rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}
	.zhuanzhang2{
		width: 90%;
		padding: 20rpx;
		border-radius: 10rpx;
		border: 1rpx solid #89b6f0;
		margin-top: 30rpx;
		margin-bottom: 20rpx;
	}
	.zuanzhe1{
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 28rpx;
		margin-left: 20rpx;
		margin-bottom: 20rpx;
		margin-top: 20rpx;
	}
	.zuanzhe2{
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-right: 25rpx;
	}
	.zuanzhe2-radio{
		transform:scale(0.8);
	}
	.queren{
		width: 90%;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #89b6f0;
		border-radius: 20rpx;
		margin-top: 160rpx;
	}
	.queren:active{
		border: 1rpx solid #89b6f0;
		background-color: #4e4e4e;
	}
	/* 切换语言 */
	.yuyan {
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 24rpx;
	}
	
	.shaoma {
		width: 45rpx;
		height: 45rpx;
	}
	
	.qiehuanimg {
		width: 45rpx;
		height: 45rpx;
		margin-left: 15rpx;
	}
	/* 弹框 */
	.qiehuantk {
		width: 600rpx;
		height: 280rpx;
		background-color: #ffffff;
		display: flex;
		color: #000;
		flex-direction: column;
		border-radius: 20rpx;
	}
	
	.qiehuantk1 {
		width: 100%;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	
	}
	
	.qiehuantk1:active {
		background-color: #ececec;
	}
	
</style>